package com.atstudy.state;

import java.util.concurrent.locks.LockSupport;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2022/12/23 15:15
 * @copyright: 博为峰
 */
public class LockSupportDemo {

    public static Object obj = new Object();

    public static void main(String[] args) {
        Thread thread = new Thread(new Runnable() {//Thread-0
            @Override
            public void run() {
                synchronized (obj) {
                    System.out.println(Thread.currentThread().getName() + "-A");
                    LockSupport.park();//阻塞
                    System.out.println(Thread.currentThread().getName() + "-B");
                }
            }
        });
        thread.start();

        synchronized (obj) {
            System.out.println(Thread.currentThread().getName() + "-C");
            LockSupport.unpark(thread);//阻塞
        }
    }
}
